package cn.flying.cloud.system.view;

import javax.annotation.Resource;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.flying.cloud.system.common.service.CodeService;
import cn.flying.cloud.system.log.entity.SysSeqInfo;
import cn.flying.cloud.system.log.service.SysSeqInfoService;

/**
 * 序列号表 前端控制器
 *
 * @author: admin
 * @date: 2023年04月19日 16:27
 * @version: 1.0
 */
@Controller
@RequestMapping("/sys/seqInfo")
public class SysSeqViewController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private SysSeqInfoService sysSeqInfoService;
    @Resource
    private CodeService codeService;

    /**
     * 跳转到列表页面
     *
     * @return
     */
    @RequestMapping("index")
    public String list(Model model) {
        Map<String, String> statusList = codeService.getCodeList("status");
        model.addAttribute("statusList", statusList);
        return "sys/seq/index";
    }

    /**
     * 新增/修改页面
     *
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("turn/edit")
    public String turnEdit(Long id, Model model) {
        if (null != id) {
            SysSeqInfo seqInfo = sysSeqInfoService.getById(id);
            model.addAttribute("seqInfo", seqInfo);
        } else {
            SysSeqInfo seqInfo = new SysSeqInfo();
            seqInfo.setStatus("Y");
            model.addAttribute("seqInfo", seqInfo);
        }
        return "sys/seq/edit";
    }
}
